package com.ashley.day_03;

public class BitTest {

	public static void main(String[] args) {
		int i = 13;
		System.out.println("i << 2 :" + (i << 2));//i << 2 :52
		System.out.println("i << 27 :" + (i << 27));//i << 27 :1744830464
		System.out.println("i << 28 :" + (i << 28));//i << 28 :-805306368
		System.out.println("i >> 2 :" + (i >> 2));//i >> 2 :3

		int m = 8;
		int n = 2;
		System.out.println("m & n :" + (m & n));//m & n :0
		System.out.println("m | n :" + (m | n));//m | n :10
		System.out.println("m ^ n :" + (m ^ n));//m ^ n :10

		// 交换两个变量的值
		int num1 = 10;
		int num2 = 20;
		int temp = num1;
		num1 = num2;
		num2 = temp;
		System.out.println("num1 = " + num1 + ",num2 = " + num2);//num1 = 20,num2 = 10

	}

}
